<template>
  <div class="study-plan-card">
    <div class="StudyHead">
      <div class="StudyHead-avatar">
        <img :src="plan.headerUrl" alt="头像" />
      </div>
      <div class="StudyHead-info">
        <p class="StudyHead-name">{{ plan.username }}</p>
        <p class="StudyHead-label">
          {{ plan.description == null ? '' : plan.description.slice(0, 15) + '...' }}
        </p>
      </div>
      <div class="StudyHead-tag">
        <span v-for="(tag, index) in plan.tags" :key="index" class="tag-item"
          ><img
            src="https://vue-wj.oss-cn-beijing.aliyuncs.com/icon/%E6%A0%87%E7%AD%BE_1.png"
            alt=""
          /><span>{{ tag.name }}</span></span
        >
      </div>
    </div>
    <div class="StudyHead-line">
      <div class="StudyHead-line-item" v-for="item in plan.task" :key="item.id">
        <img src="@/assets/img/checked.png" alt="完成任务" width="30px" v-if="item.isDo === 1" />
        <img src="@/assets/img/unchecked.png" alt="未完成任务" width="30px" v-else />
        <div class="StudyHead-title">
          {{ item.task.slice(0, 40) + '...' }}
        </div>
        <div class="StudyHead-time">
          <span>{{ item.startTime }}~{{ item.endTime }}</span>
        </div>
      </div>
    </div>
    <div class="StudyHead-foot">
      <div class="StudyHead-foot-Like"><van-icon name="like-o" />&nbsp;{{ plan.likeCount }}</div>
      <div class="StudyHead-foot-Comment">
        <van-icon name="chat-o" />&nbsp;{{ plan.commonCount }}
      </div>
    </div>
  </div>
</template>

<script setup>
import { Checkbox, CheckboxGroup } from 'vant'
import { ref, computed, onMounted } from 'vue'

const props = defineProps({
  plan: {
    type: Object,
    default: {},
  },
})

//模拟数据

const disableClick = () => {}
const FomateData = () => {
  for (let i = 0; i < props.plan.task.length; i++) {
    if (props.plan.task[i].isDo === 0) {
      props.plan.task[i].isDo = true
    } else {
      props.plan.task[i].isDo = false
    }
  }
}

/**
 * 初始化数据，将数据中的checked字段转为布尔值
 */
onMounted(() => {})
</script>

<style lang="scss" scoped>
.study-plan-card {
  font-family: '猫糖圆体';
  min-height: 150px;
  margin: 5px 0px;
  padding: 15px;
  background-color: #ffffff71;
  border-radius: 12px;
  backdrop-filter: blur(10px);
  border: 0.3px solid #333;
  .StudyHead {
    display: flex;
    justify-content: space-between;
    .StudyHead-info {
      width: auto;
      flex: auto;
      padding-left: 8px;
      .StudyHead-title {
        font-size: 12px;
      }
      .StudyHead-label {
        font-size: 10px;
        margin-top: 5px;
      }
    }
    .StudyHead-tag {
      display: flex;
      height: 25px;
      width: auto;
      .tag-item {
        margin-right: 5px;
        padding: 3px 3px;
        border-radius: 8px;
        font-size: 10px;
        background-color: rgba(172, 236, 248, 0.5);
        color: rgb(78, 133, 228);
        line-height: 20px;
        display: flex;
        align-items: center;
        img {
          width: 16px;
        }
      }
    }
    .StudyHead-avatar {
      width: 35px;
      height: 35px;
      border-radius: 50%;
      overflow: hidden;
      img {
        width: 100%;
        height: 100%;
      }
    }
  }
  .StudyHead-line {
    padding: 8px 0px;
    .StudyHead-line-item {
      display: flex;
      justify-content: space-between;
      padding: 8px 5px;
      margin: 5px 0px;
      background-color: rgba(0, 0, 0, 0.03);
      border-radius: 10px;
    }
    .StudyHead-title {
      padding-left: 8px;
      font-size: 12px;
      flex: 1;
    }
    .StudyHead-time {
      font-size: 10px;
      display: flex;
      align-items: center;
      justify-content: start;
      font-weight: bold;
    }
  }
  .StudyHead-foot {
    display: flex;
    justify-content: start;
    gap: 10px;
  }
}
</style>